package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.stream.IntStream;

import com.ruoyi.system.domain.PointsRuleSystem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.PointsRuleArtificialMapper;
import com.ruoyi.system.domain.PointsRuleArtificial;
import com.ruoyi.system.service.IPointsRuleArtificialService;

/**
 * 人工积分规则Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-22
 */
@Service
public class PointsRuleArtificialServiceImpl implements IPointsRuleArtificialService
{
    @Autowired
    private PointsRuleArtificialMapper pointsRuleArtificialMapper;

    /**
     * 查询人工积分规则
     *
     * @param id 人工积分规则主键
     * @return 人工积分规则
     */
    @Override
    public PointsRuleArtificial selectPointsRuleArtificialById(Long id)
    {
        return pointsRuleArtificialMapper.selectPointsRuleArtificialById(id);
    }

    /**
     * 查询人工积分规则列表
     *
     * @param pointsRuleArtificial 人工积分规则
     * @return 人工积分规则
     */
    @Override
    public List<PointsRuleArtificial> selectPointsRuleArtificialList(PointsRuleArtificial pointsRuleArtificial)
    {
        List<PointsRuleArtificial> pointsRuleArtificials = pointsRuleArtificialMapper.selectPointsRuleArtificialList(pointsRuleArtificial);
        IntStream.range(0,pointsRuleArtificials.size()).forEach(
                i->{
                    int index = i+1;
                    PointsRuleArtificial pointsRuleArtificialVo = pointsRuleArtificials.get(i);
                    pointsRuleArtificialVo.setOrderNum(index);
                });
        return pointsRuleArtificials;
    }

    /**
     * 新增人工积分规则
     *
     * @param pointsRuleArtificial 人工积分规则
     * @return 结果
     */
    @Override
    public int insertPointsRuleArtificial(PointsRuleArtificial pointsRuleArtificial)
    {
        return pointsRuleArtificialMapper.insertPointsRuleArtificial(pointsRuleArtificial);
    }

    /**
     * 修改人工积分规则
     *
     * @param pointsRuleArtificial 人工积分规则
     * @return 结果
     */
    @Override
    public int updatePointsRuleArtificial(PointsRuleArtificial pointsRuleArtificial)
    {
        return pointsRuleArtificialMapper.updatePointsRuleArtificial(pointsRuleArtificial);
    }

    /**
     * 删除人工积分规则信息
     *
     * @param id 人工积分规则主键
     * @return 结果
     */
    @Override
    public int deletePointsRuleArtificialById(Long id)
    {
        return pointsRuleArtificialMapper.deletePointsRuleArtificialById(id);
    }
}
